#!/bin/sh
total=144
csvFile='output.csv'
mFile='matchingFile.txt'
nmFile='nonmatchingFile.txt'


rm $csvFile
rm $mFile
rm $nmFile

echo -n "," >> $csvFile

for n in $(seq $total)
do 
echo  -n ${n}l.tif, >> $csvFile
done

for n in $(seq $total)
do
echo -n ${n}r.tif, >> $csvFile
done
echo >> $csvFile

for probe in $(seq $total)
do
echo -n ${probe}l.tif, >> $csvFile
for gallery in $(seq $total)
do
tempScore=`./matcher -p class/${probe}l.tif -g class/${gallery}l.tif`
echo -n $tempScore >> $csvFile
#output matching/nonmatching score
tempProbe=`expr $probe - 1`
tempProbe=`expr $tempProbe / 6`
tempGallery=`expr $gallery - 1`
tempGallery=`expr $tempGallery / 6`
if [ $tempProbe = $tempGallery ]; then
echo $tempScore >> $mFile
else
echo $tempScore >> $nmFile
fi

done
for gallery in $(seq $total)
do
tempScore=`./matcher -p class/${probe}l.tif -g class/${gallery}r.tif`
echo -n $tempScore >> $csvFile
#no images will match here since it's lefts vs rights
echo $tempScore >> $nmFile
done
echo >> $csvFile
done

for probe in $(seq $total)
do
echo -n ${probe}r.tif, >> output.csv
for gallery in $(seq $total)
do
tempScore=`./matcher -p class/${probe}r.tif -g class/${gallery}l.tif`
echo -n $tempScore >> $csvFile
#no images will match here since it's lefts vs rights
echo $tempScore >> $nmFile
done
for gallery in $(seq $total)
do
tempScore=`./matcher -p class/${probe}r.tif -g class/${gallery}r.tif`
echo -n $tempScore >> $csvFile
#output matching/nonmatching score
tempProbe=`expr $probe - 1`
tempProbe=`expr $tempProbe / 6`
tempGallery=`expr $gallery - 1`
tempGallery=`expr $tempGallery / 6`
if [ $tempProbe = $tempGallery ]; then
echo $tempScore >> $mFile
else
echo $tempScore >> $nmFile
fi
done
echo >> $csvFile
done
